package ca.ets.osgi.composedservice;

import java.util.ArrayList;
public class User {
	
	private ConcreteEvent event;
	private PlaneTicket ticket;
	private HotelReservation hotel; 
	
	
	
	public User(){}



	/**
	 * @return the event
	 */
	public ConcreteEvent getEvent() {
		return event;
	}
	
	/**
	 * @param event the event to set
	 */
	public void setEvent(ConcreteEvent event) {
		this.event = event;
	}
	
	public void convertObjectListToEvent(ArrayList<Object> obj){
		event = new ConcreteEvent();
		try {
			event.setNom((String) obj.get(0));
			event.setNoID((Integer)obj.get(1));
			event.setStartDate((String) obj.get(2));
			event.setEndDate((String) obj.get(3));
			event.setTelephone((String) obj.get(4));
			Adresse adr = new Adresse();
			
			adr.setAdresseNum((Integer)obj.get(5));
			adr.setRue((String) obj.get(6));
			adr.setVille((String) obj.get(7));
			adr.setProvince((String) obj.get(8));
			adr.setCodePostal((String) obj.get(9));
			event.setAdresse(adr);		
		}catch(Exception e){
			
		}
		
	}



	/**
	 * @return the ticket
	 */
	public PlaneTicket getTicket() {
		return ticket;
	}



	/**
	 * @param ticket the ticket to set
	 */
	public void setTicket(PlaneTicket ticket) {
		this.ticket = ticket;
	}
	
	/**
	 * Create a ticket from a list
	 * @param obj
	 */
	public void convertObjectListToTicket(ArrayList<Object> obj){
		ticket = new PlaneTicket();
		
		try {
			ticket.setAirportID((String) obj.get(0));
			ticket.setPhone((String) obj.get(1));
			ticket.setFlightID((String) obj.get(2));
			ticket.setAirportArrival((String) obj.get(3));
			ticket.setAirportDeparture((String) obj.get(4));
			ticket.setCityArrival((String) obj.get(5));
			ticket.setCityDeparture((String) obj.get(6));
			ticket.setDateDeparture((String) obj.get(7));
			ticket.setDateReturn((String) obj.get(8));
			
			Adresse adr = new Adresse();
			
			adr.setAdresseNum( (Integer)obj.get(9));
			adr.setRue((String) obj.get(10));
			adr.setVille((String) obj.get(11));
			adr.setProvince((String) obj.get(12));
			adr.setCodePostal((String) obj.get(13));
			
			ticket.setAdresse(adr);
			
		}catch(Exception e){
			
		}
		
		
		
	}



	/**
	 * @return the hotel
	 */
	public HotelReservation getHotel() {
		return hotel;
	}



	/**
	 * @param hotel the hotel to set
	 */
	public void setHotel(HotelReservation hotel) {
		this.hotel = hotel;
	}
	
	/**
	 * Convert the list of Object to an hotel reservation
	 * @param obj
	 */
	public void convertObjectListToHotel(ArrayList<Object> obj){
		hotel = new HotelReservation();
		try {
			hotel.setHotelID((String) obj.get(0));
			hotel.setHotelName((String) obj.get(1));
			hotel.setPhone((String) obj.get(2));
			hotel.setDateStart((String) obj.get(3));
			hotel.setDateEnd((String) obj.get(4));
			Adresse adr = new Adresse();
			
			adr.setAdresseNum( (Integer)obj.get(5));
			adr.setRue((String) obj.get(6));
			adr.setVille((String) obj.get(7));
			adr.setProvince((String) obj.get(8));
			adr.setCodePostal((String) obj.get(9));
			
			hotel.setAdresse(adr);

		}catch(Exception e){
			
		}
		
	}

}
